# Definition for a binary tree node.
import collections
class TreeNode(object):
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution(object):
    def searchBST(self, root, val):
        """
        :type root: TreeNode
        :type val: int
        :rtype: TreeNode
        """
        if not root:
            return None
        queue = collections.deque()
        queue.append(root)
        while queue:
            node = queue.pop()
            if node:
                if node.val == val:
                    return node
                if node.val < val:
                    queue.append(node.right)
                    
                else:
                    queue.append(node.left)
        return None